#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        //child
        printf("pid:%d, exec command begin\n", getpid());
        sleep(3);
        execl("/usr/bin/ls","ls", "-a", "-l", "-n", NULL);
        printf("pid:%d, exec command end\n", getpid());
    }
    else 
    {
        // father
        pid_t rid = waitpid(-1 ,NULL, 0);
        if(rid > 0)
            printf("wait success, rid: %d\n", rid);
    }
    return 0;
}

